#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#define N 1000
int xy[N][N];
int yz[N][N];
int xz[N][N];
using namespace std;
int main()
{
	
	
	int n, q;
	int count = 0;
	scanf("%d%d", &n, &q);
	while (q--)
	{
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		xy[x][y]++;
		yz[y][z]++;
		xz[x][z]++;
		if (xy[x][y] == n)
		{
			count++;
		}
		if (yz[y][z] == n)
		{
			count++;
		}
		if (xz[x][z] == n)
		{
			count++;
		}
		printf("%d\n", count);
	}
	double arr[10];
	return 0;
}
